/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author Matthy & Jelle
 */
public abstract class AbstractService {

  public boolean save(Object o) {
    if (this.validate(o)) {
      Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      Transaction tx = session.beginTransaction();
      session.saveOrUpdate(o);
      tx.commit();
      return true;
    }
    return false;
  }

  public abstract boolean validate(Object o);
}
